﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EzDesk.Attendance.MobileWeb.Controllers.Attendance
{
    class DateTimeHelper
    {
        internal static void GetAWeek(out DateTime thisWeekStart, out DateTime thisWeekEnd)
        {
            GetAWeek(DateTime.Now, out thisWeekStart, out thisWeekEnd);
        }

        internal static void GetAWeek(DateTime timePoint, out DateTime weekStart, out DateTime weekEnd)
        {
            weekStart = timePoint.AddDays(-(double)timePoint.DayOfWeek);
            weekEnd = timePoint.AddDays((double)(6 - timePoint.DayOfWeek));
        }




        internal static void GetAMonth(out DateTime monthStart, out DateTime monthEnd)
        {
            GetAMonth(DateTime.Now, out monthStart, out monthEnd);
        }

        internal static void GetAMonth(DateTime timePoint, out DateTime monthStart, out DateTime monthEnd)
        {
            monthStart = new DateTime(
                timePoint.Year,
                timePoint.Month,
                1,
                0, 0, 0);
            monthEnd = monthStart.AddMonths(1).AddDays(-1);
        }




        internal static string DayOfWeekString(DayOfWeek dayOfWeek)
        {
            switch ((int)dayOfWeek)
            {
                case 0: return "星期日";
                case 1: return "星期一";
                case 2: return "星期二";
                case 3: return "星期三";
                case 4: return "星期四";
                case 5: return "星期五";
                case 6: return "星期六";
                default :
                    throw new Exception();
            }

        }

    }
}
